package com.mzj.saas.mservice.pay.controller;

import com.mzj.saas.mservice.pay.service.WxPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 微信
 *
 * @author qixi
 */
@Controller
@RequestMapping("/wxPay")
public class WxPayController {

    @Autowired
    private WxPayService wxPayService;

    /**
     * 微信app支付后端回调通知
     *
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping("/appPayCallback")
    @ResponseBody
    public void appPayCallback(HttpServletRequest request, HttpServletResponse response) throws Exception {
        wxPayService.appPayCallback(request, response);
    }

    @RequestMapping("/test")
    @ResponseBody
    public void test(HttpServletRequest request, HttpServletResponse response) throws Exception {
        wxPayService.handleAioScanPay("8136507109007241216", null, 2);
    }

    /**
     * 微信小程序支付后端回调通知
     *
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping("/appletPayCallback")
    @ResponseBody
    public void appletPayCallback(HttpServletRequest request, HttpServletResponse response) throws Exception {
        wxPayService.appletPayCallback(request, response);
    }
}
